package cn.edu.neusoft.wuguangsheng.market.adapter;

import android.content.Context;
import android.content.Intent;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.squareup.picasso.Picasso;

import java.util.List;

import cn.edu.neusoft.wuguangsheng.market.activity.InsertCommentActivity;
import cn.edu.neusoft.wuguangsheng.market.bean.OrderFoodInfo;

/**
 * Created by little on 2018/4/22.
 */

public class OrderInfoAdapter extends BaseAdapter<OrderFoodInfo> {
    public OrderInfoAdapter(Context context, List<OrderFoodInfo> items, int layoutResource){
        super(context, items, layoutResource);
    }

    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View itemView= LayoutInflater.from(context)
                .inflate(layoutResourse,parent,false);
        CommentViewHolder commentViewHolder=new CommentViewHolder(itemView);
        return commentViewHolder;
    }

    @Override
    public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
        CommentViewHolder commentViewHolder=(CommentViewHolder)holder;
        OrderFoodInfo orderFoodInfo=items.get(position);
        final String fid=orderFoodInfo.getFid();
        final String name=orderFoodInfo.getHc();
        commentViewHolder.or_tv1.setText("菜名:"+name);

        final String mrid=orderFoodInfo.getMrid();
        final String num=orderFoodInfo.getNum();
        commentViewHolder.or_tv2.setText("数量:"+num);
        final String sum=orderFoodInfo.getAllsum();

        commentViewHolder.or_tv3.setText("合计:￥"+sum);
        final String orid=orderFoodInfo.getOrid();

        Picasso.with(context).load(items.get(position).getPic()).into(commentViewHolder.or_img);
        commentViewHolder.or_pl.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent1 = new Intent(context, InsertCommentActivity.class);
                intent1.putExtra("orid",orid);
                intent1.putExtra("fid",fid);
                intent1.putExtra("mrid",mrid);
                context.startActivity(intent1);
            }
        });
    }


}
